<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<view class="text-area">
			<text class="title">{{title}}</text>
		</view>
    <button @click="testObj">测试云对象</button>
    <button @click="testFun">测试云函数</button>
    <button @click="getDp">得到dp</button>
    <button @click="getDetail">得到dp详情</button>
    <button @click="updateDp">修改dp</button>
    <button @click="addDp">新增dp</button>
    <button @click="deleteDp">删除dp</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello'
			}
		},
		onLoad() {

		},
		methods: {
      async testObj() {
        const test2 = uniCloud.importObject('test2')
        const res = await test2.sum(7, 9)
        console.log(res)
      },
      async testFun() {
        const res = await uniCloud.callFunction({
          name: 'test1',
          data: { a: 3, b: 5 }
        })
        console.log(res.result)
      },
      async getDp() {
        const dp = uniCloud.importObject('dp')
        const res = await dp.getInfo(0, 20)
        console.log(res)
      },
      updateDp() {
        const dp = uniCloud.importObject('dp')
        dp.updateInfo('676d1d5432f3f52e8f3ab8cf')
      },
      addDp() {
        const dp = uniCloud.importObject('dp')
        const data = {
          name: '大幅度',
          price: 25,
          address: '北京市海淀区长春桥',
          status: 0
        }
        dp.addDp(data)
      },
      deleteDp() {
        const dp = uniCloud.importObject('dp')
        dp.deleteDp('676d2459d3d3a985129346a8')
      },
      async getDetail() {
        const dp = uniCloud.importObject('dp')
        // const res = await dp.getDetail('676e0fedd3cbadf4d5f519eb')
        const res = await dp.getDetail('涿州市')
        console.log(res)
      }
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
